#import "@preview/tablex:0.0.6": tablex, rowspanx, colspanx
#import "@preview/tbl:0.0.4"
#import "@preview/algo:0.3.6": algo, i, d, comment, code
// 模版设置
#let template(title: none, doc) = {

  // 设置语言，插图、表格、目录编号等与语言相关
  set text(lang: "zh")

  // 设置字体
  set text(font: ("Arial", "simsun"), size: 10.5pt)

  // 设置页面
  set page(
    header: rect(
    stroke: (bottom: 1pt + black), // 仅显示下边框
    width: 100%,
    [#title #h(1fr) #box(image("logo_leawa.png", height: 0.5cm))]),
    paper: "a4", 
    margin: (x: 2.5cm, y: 2.5cm),  
    numbering: "1"
    )
    
  // 设置标题编号
  set heading(numbering: "1.")

  // 设置列表
  set enum(numbering: "（1）", indent: 2em)
  set list(indent: 2em)

  // 设置表格标题位于表格顶部
  //set figure.caption(position: top)
  show figure.where(
    kind: table
    ): set figure.caption(position: top)
  show table: it => align(center)[#it]
    
  show figure.where(
    kind: table
    ): set figure.caption(position: top)


  // 设置图表编号方式
  set figure(numbering: "1")
  set figure.caption(separator: [.  ])

  // 文档标题
  set align(center)
  text(16pt, title)

  // 段落设置
  set align(left)
  // 段首缩进2字符
  set par(first-line-indent: (amount: 2em, all: true))

  // 代码块
  show raw.where(block: true): box.with(
  inset: (x: 0.5em, y: 0em),
  fill: luma(240),
  outset: (y: 0.7em),
  width: 96%          // 去除前面的缩进
)

  // 文档内容
  doc
}